<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|Roboto Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="MySQL,分布式,分库分表,">










<meta name="description" content="什么时候需要分库分表分库分库主要解决并发量过高的问题。 当并发上来了，单库的链接数就有可能成为瓶颈，这时候增加数据库实例以提高系统并发度。 常见的分库场景会按照微服务业务来拆分(垂直)：">
<meta name="keywords" content="MySQL,分布式,分库分表">
<meta property="og:type" content="article">
<meta property="og:title" content="浅谈分库分表">
<meta property="og:url" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/index.html">
<meta property="og:site_name" content="Yu&#39;s Home">
<meta property="og:description" content="什么时候需要分库分表分库分库主要解决并发量过高的问题。 当并发上来了，单库的链接数就有可能成为瓶颈，这时候增加数据库实例以提高系统并发度。 常见的分库场景会按照微服务业务来拆分(垂直)：">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/D0F307C0-7BD7-4013-93F9-9E72FBCADF7D.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/8D9497C0-B99D-41D7-931F-E10704F8FFCB.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/335E2125-5F4F-4B4B-BAFB-3FD500E0F342.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/CCD2E887-108C-42D3-9E3C-14D9C3B2C270.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/2D2AC353-8F98-478D-9320-CE133F7C4D19.jpg">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/5501D4C1-9CF9-4973-8656-0DA27374E61C.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/DE99CCD2-3696-471C-B03F-7C22DDB20CF8.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/image-20230225121127761.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/B1333002-C535-4FA0-9F38-5B9105F41797.png">
<meta property="og:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/B6C0B6B5-18A5-4B8A-8D76-59A005A3E41C.png">
<meta property="og:updated_time" content="2023-02-25T04:29:35.429Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="浅谈分库分表">
<meta name="twitter:description" content="什么时候需要分库分表分库分库主要解决并发量过高的问题。 当并发上来了，单库的链接数就有可能成为瓶颈，这时候增加数据库实例以提高系统并发度。 常见的分库场景会按照微服务业务来拆分(垂直)：">
<meta name="twitter:image" content="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/D0F307C0-7BD7-4013-93F9-9E72FBCADF7D.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"hide","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '9PFXHHRD2G',
      apiKey: '45293228d8a5cecc1c0826fb3d34a130',
      indexName: 'blog',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"没有找到任何结果: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/">





  <title>浅谈分库分表 | Yu's Home</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?1746d8de4fb78edd21f9004d348fa6be";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Yu's Home</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">管它真理无穷</h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于Yu
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Yu">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/xiaomai.png">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Yu's Home">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">浅谈分库分表</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2022-05-25T11:41:00+08:00">
                2022-05-25
              </time>
            

            

            
          </span>

          

          
            
              <span class="post-comments-count">
              <span class="post-meta-divider">|</span>
              <span class="post-meta-item-icon">
              <i class="fa fa-comment-o"></i>
              </span>
              <a href="/2022/05/25/浅谈分库分表/#comments" itemprop="discussionUrl">
              <span class="post-comments-count valine-comment-count" data-xid="/2022/05/25/浅谈分库分表/" itemprop="commentCount"></span>
              </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2,120
                </span>
              

              

              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="什么时候需要分库分表"><a href="#什么时候需要分库分表" class="headerlink" title="什么时候需要分库分表"></a>什么时候需要分库分表</h2><h3 id="分库"><a href="#分库" class="headerlink" title="分库"></a>分库</h3><p>分库主要解决并发量过高的问题。</p>
<p>当并发上来了，单库的链接数就有可能成为瓶颈，这时候增加数据库实例以提高系统并发度。</p>
<p>常见的分库场景会按照微服务业务来拆分(垂直)：</p>
<img src="/2022/05/25/浅谈分库分表/D0F307C0-7BD7-4013-93F9-9E72FBCADF7D.png" alt="d74af2eb1d2082c2cfa58d7e93c23481" style="zoom:50%;">

<a id="more"></a>

<h3 id="分表"><a href="#分表" class="headerlink" title="分表"></a>分表</h3><p>分表主要解决单表数据量过大的问题。</p>
<blockquote>
<p>数据量过大引起性能瓶颈的主要原因：<br>内存缓冲有限，更多的数据量意味着查找时需要更多的页换入换出</p>
</blockquote>
<img src="/2022/05/25/浅谈分库分表/8D9497C0-B99D-41D7-931F-E10704F8FFCB.png" alt="cf3c354bc78714fab7f3a8bc409bf951" style="zoom:50%;">

<p>什么时候数据量才算多呢？这个其实有很多因素，机器配置，MySQL配置，列数据大小等等。</p>
<p>我们一般进行简单评估，按照《阿里巴巴开发手册》中提到：单表行数超过 500 万行或者单表容量超过 2GB，才推荐进行分库分表。<br>说明：如果预计三年后的数据量根本达不到这个级别，请不要在创建表时就分库分表</p>
<h3 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h3><table>
<thead>
<tr>
<th>切分方式</th>
<th>应用场景</th>
</tr>
</thead>
<tbody><tr>
<td>只分库不分表</td>
<td>数据库读/写 QPS过高，链接数不足</td>
</tr>
<tr>
<td>只分表不分库</td>
<td>数据量过大，性能瓶颈</td>
</tr>
<tr>
<td>既分库又分库</td>
<td>并发高 + 数据量过大</td>
</tr>
</tbody></table>
<h2 id="垂直-水平拆分"><a href="#垂直-水平拆分" class="headerlink" title="垂直/水平拆分"></a>垂直/水平拆分</h2><p>以用户表为例：</p>
<table>
<thead>
<tr>
<th>id</th>
<th>username</th>
<th>passwd</th>
<th>nickname</th>
<th>address</th>
<th>phone</th>
<th>…</th>
</tr>
</thead>
<tbody><tr>
<td>1</td>
<td>junjie.yu</td>
<td>***</td>
<td>yjj</td>
<td>深圳</td>
<td>150xxxxxxxx</td>
<td></td>
</tr>
</tbody></table>
<h3 id="垂直拆分"><a href="#垂直拆分" class="headerlink" title="垂直拆分"></a>垂直拆分</h3><p>垂直拆分即把一张表的列拆分到多张表中。</p>
<img src="/2022/05/25/浅谈分库分表/335E2125-5F4F-4B4B-BAFB-3FD500E0F342.png" alt="79af7769bc25e130dc133e347a65ce1a" style="zoom:60%;">

<p>这样拆分之后 user_base 可单独用于登录验证<br>user_detail_tab 用于查询和修改用户信息</p>
<h4 id="拆分特点"><a href="#拆分特点" class="headerlink" title="拆分特点"></a>拆分特点</h4><ol>
<li>每个库/表的结构不同</li>
<li>每个库/表至少有一列关联</li>
<li>每个库/表的并集是全量数据</li>
</ol>
<h4 id="优缺点"><a href="#优缺点" class="headerlink" title="优缺点"></a>优缺点</h4><p><strong>优点：</strong></p>
<ol>
<li>各个库/表可以单独维护，边界分隔开来</li>
<li>减少了每个表的数据量，提升了读写性能</li>
<li>对于有业务频繁修改字段，拆分后能够减少行锁的范围</li>
</ol>
<p><strong>缺点：</strong></p>
<ol>
<li>如果拆分后的表数据量过多，仍会有性能问题</li>
<li>改造成本较高</li>
</ol>
<h3 id="水平拆分"><a href="#水平拆分" class="headerlink" title="水平拆分"></a>水平拆分</h3><p>水平拆分即按照规则把一张表的数据分散到多张表中</p>
<img src="/2022/05/25/浅谈分库分表/CCD2E887-108C-42D3-9E3C-14D9C3B2C270.png" alt="8996ff1a86adf5e28bf3d2497ec751ee" style="zoom:60%;">

<h4 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h4><ol>
<li>每个库/表的结构相同</li>
<li>每个库/表的数据不同</li>
<li>每个库/表的并集是全量数据</li>
</ol>
<h4 id="优缺点-1"><a href="#优缺点-1" class="headerlink" title="优缺点"></a>优缺点</h4><p><strong>优点：</strong></p>
<ol>
<li>单表的数据量维持在一定量，避免数据量太大引起的性能问题</li>
<li>未拆分表结构，改造成本低</li>
</ol>
<p><strong>缺点：</strong><br>当水平hash分片时，数据扩容存在困难</p>
<h2 id="分片算法"><a href="#分片算法" class="headerlink" title="分片算法"></a>分片算法</h2><h3 id="range"><a href="#range" class="headerlink" title="range"></a>range</h3><p>范围分片即根据某一个属性范围进行。</p>
<p>比如有一张订单表，可以选择按按订单id的范围或者订单年/月分表</p>
<img src="/2022/05/25/浅谈分库分表/2D2AC353-8F98-478D-9320-CE133F7C4D19.jpg" alt="9ae55c58e5c65be57d80e80820872875" style="zoom:60%;">

<p><strong>优点：</strong><br>扩容方便，只需提前添加新的节点即可</p>
<p><strong>缺点：</strong></p>
<ol>
<li>尾部热点问题。最近的库/表属于热点数据，承载了大部分的压力</li>
<li>不好准确评估范围，可能造成资源浪费</li>
<li>数据倾斜问题。存储的时候各个库/表的数据可能不均，对外表现有波动</li>
</ol>
<h3 id="hash"><a href="#hash" class="headerlink" title="hash"></a>hash</h3><p>hash分片根据某一个属性hash取模求余的方式来选择分片。</p>
<p>比如订单表，可以按照user_id hash分片</p>
<p><img src="/2022/05/25/浅谈分库分表/5501D4C1-9CF9-4973-8656-0DA27374E61C.png" alt="04ff99ef449f892f39a23a988e0ade8c"></p>
<p>理论上，数据越多，hash分片会越倾向均匀，但还要注意选取的分片字段是否合适，否则也会导致数据分片不均衡。例如这里如果选用卖家id而不是买家id的话，就会被大卖家引起数据倾斜，而大买家的概率则小得多。</p>
<p><strong>优点：</strong><br>数据分片相对均匀</p>
<p><strong>缺点：</strong></p>
<ol>
<li>扩容相对困难，通常会引入一致性hash算法来解决扩容问题</li>
<li>不带user_id的跨库/表查询问题。在多个节点循环查找，然后在内存中组合；或者同步一份其他维度的数据，空间换时间</li>
</ol>
<h4 id="一致性hash"><a href="#一致性hash" class="headerlink" title="一致性hash"></a>一致性hash</h4><p>当hash扩容时，表的总数发生变化，这时候重新计算hash时就涉及到了数据迁移。</p>
<p><img src="/2022/05/25/浅谈分库分表/DE99CCD2-3696-471C-B03F-7C22DDB20CF8.png" alt="b88e35ac93a315e468f0d2103b76cf9b"></p>
<p>一致性哈希按照常用的hash算法将对应的key哈希到一个2^32次方节点的空间中，形成一个顺时针的闭合环，数据存储到顺时针方向的第一个节点当中，当添加一台新的服务器时，只会和逆时针方向第一台服务器之间产生数据迁移。</p>
<p>并且为避免数据倾斜，引入许多虚拟节点，在环上均匀划分，然后映射虚拟节点和物理节点的关系，实现数据均衡划分。</p>
<h2 id="结合业务场景"><a href="#结合业务场景" class="headerlink" title="结合业务场景"></a>结合业务场景</h2><p>当 user_tab 按照 user_id 分表时，登录需要支持按 username 登录。<br>如果用 username 来查找用户就需要在所有表进行查询，如何优化？</p>
<h3 id="倒排索引法"><a href="#倒排索引法" class="headerlink" title="倒排索引法"></a>倒排索引法</h3><p>空间换时间，可以通过构建倒排的映射关系来找到用户所在分表。<br>存储后端可以是redis, es等</p>
<table>
<thead>
<tr>
<th>key</th>
<th>v[user_id, partition_id]</th>
</tr>
</thead>
<tbody><tr>
<td>username:junjie.yu</td>
<td>1, 1</td>
</tr>
<tr>
<td>Username:zhang.san</td>
<td>8, 2</td>
</tr>
<tr>
<td>mobile:150xxxxxxxx</td>
<td>8, 2</td>
</tr>
</tbody></table>
<p><strong>优点：</strong> 通用方案，适用于所有分库分表场景下的搜索<br><strong>缺点：</strong></p>
<ol>
<li>有一次额外查询</li>
<li>数据存储加倍，如果需要反向搜索的key过多，额外的空间开销会很大</li>
<li>数据一致性问题。需要维护数据库和索引缓存的一致性</li>
</ol>
<h3 id="基因法"><a href="#基因法" class="headerlink" title="基因法"></a>基因法</h3><p>因为username由用户传递不可变，把username中的末尾固定几位作为分表基因，加入到user_id当中，使按照user_id路由和按username中的末尾几位得到的路由分片相同。</p>
<img src="/2022/05/25/浅谈分库分表/image-20230225121127761.png" alt="image-20230225121127761" style="zoom:50%;">


<p>基因法有很多变种，具体场景具体分析，核心思想是存储数据上带上”基因”，能够根据这段”基因”找到路由分片。</p>
<p>例如：<br><img src="/2022/05/25/浅谈分库分表/B1333002-C535-4FA0-9F38-5B9105F41797.png" alt="4ae06af15ffc6d5040fd42799430d782"></p>
<p><strong>优点：</strong> 性能好，不需要额外查询<br><strong>缺点：</strong></p>
<ol>
<li>分库/表的节点数量需要提前规划，因为分片”基因”的数据迁移非常困难</li>
<li>对于影响到主键id生成的场景，需要对全局id生成器做改造</li>
<li>除了获取基因的字段之外，只有非业务含义的字段在生成时能够添加”基因”(例如例子中的user_id和order_id)，因为业务字段的值有含义，没有添加基因的条件。<blockquote>
<p>比如username这个场景，mobile_phone就不能添加基因了</p>
</blockquote>
</li>
</ol>
<p>总结：基因法性能好，但前提条件较多，建议只使用在关键业务字段上。</p>
<h2 id="分表存在的其他问题"><a href="#分表存在的其他问题" class="headerlink" title="分表存在的其他问题"></a>分表存在的其他问题</h2><h3 id="全局id"><a href="#全局id" class="headerlink" title="全局id"></a>全局id</h3><h4 id="范围分片"><a href="#范围分片" class="headerlink" title="范围分片"></a>范围分片</h4><p>提前规划好范围，设置各个分片的自增id起始值</p>
<h4 id="UUID-不推荐"><a href="#UUID-不推荐" class="headerlink" title="UUID(不推荐)"></a>UUID(不推荐)</h4><p>UUID能够生成全局唯一的128位的字符串。</p>
<p>但缺点一是字符串做主键效率相对较低，二是UUID无序会导致InnoDB底层B+存储不断进行索引重排，页分裂频繁</p>
<h4 id="Snowflake雪花算法-推荐"><a href="#Snowflake雪花算法-推荐" class="headerlink" title="Snowflake雪花算法(推荐)"></a>Snowflake雪花算法(推荐)</h4><p>雪花算法其具有简洁、高性能、低延迟、ID 按时间趋势有序等特点</p>
<p><img src="/2022/05/25/浅谈分库分表/B6C0B6B5-18A5-4B8A-8D76-59A005A3E41C.png" alt="4c3b6ee159d990ad5d6f25f9f67466b6"></p>
<ul>
<li>41 位时间戳，可以使用 69 年，年数 = (1L &lt;&lt; 41) / (1000L * 60 * 60 * 24 * 365) ≈ 69</li>
<li>10 位机器位，可以部署 1024 个节点，包括 5 位 datacenterId 和 5 位 workerId</li>
<li>12 位序列号，毫秒内计数，支持每个节点每毫秒产生 4096 个不重复 ID 序号</li>
</ul>
<p><strong>一毫秒能够生成 1024x4096=4194304个不同的id</strong></p>
<blockquote>
<p>注意：需要考虑时钟回拨问题</p>
</blockquote>
<h3 id="跨库-表分页，排序"><a href="#跨库-表分页，排序" class="headerlink" title="跨库/表分页，排序"></a>跨库/表分页，排序</h3><ol>
<li>程序在多个分片查询，内存整合</li>
<li>数据异构到es搜索引擎</li>
</ol>
<h3 id="分布式事务"><a href="#分布式事务" class="headerlink" title="分布式事务"></a>分布式事务</h3><p>Seata 是阿里开源的分布式事务解决方案。目前包含的方案：AT, TCC, SAGA, XA</p>
<blockquote>
<p>refer: <a href="https://seata.io/zh-cn/docs/dev/mode/at-mode.html" target="_blank" rel="noopener">https://seata.io/zh-cn/docs/dev/mode/at-mode.html</a></p>
</blockquote>
<p>其中 XA 利用了数据库的两阶段提交，CP模式，强一致性但性能低；</p>
<p>AT 也是两阶段提交思想，但为了打破XA的阻塞性，利用全局锁+undolog补偿来实现分布式事务，非强一致性，性能比 XA 有所提升；</p>
<p>TCC和SAGA都对业务有侵入，都是补偿性的事务思想。</p>
<p>但对于大部分业务场景，不需要太强的一致性，只追求最终一致性即可，通过消息表，mq，补偿等手段来实现最终一致性。</p>
<h2 id="分库分表的工具选型"><a href="#分库分表的工具选型" class="headerlink" title="分库分表的工具选型"></a>分库分表的工具选型</h2><p>代理层：ShardingSphere-Proxy</p>
<p><a href="https://shardingsphere.apache.org/document/current/cn/overview/#shardingsphere-proxy" target="_blank" rel="noopener">https://shardingsphere.apache.org/document/current/cn/overview/#shardingsphere-proxy</a></p>
<p>应用层：gorm scopes, gorm-sharding</p>
<p><a href="https://github.com/go-gorm/gorm/issues/5272" target="_blank" rel="noopener">https://github.com/go-gorm/gorm/issues/5272</a></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>觉得好的话就打赏Ta一瓶冰阔落吧</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechatpay.jpg" alt="Yu 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.jpg" alt="Yu 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
      <div>
        <ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者：</strong>
    Yu
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/" title="浅谈分库分表">https://yujunjiex.gitee.io/2022/05/25/浅谈分库分表/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>
    本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 3.0</a> 许可协议。转载请注明出处！
  </li>
</ul>

      </div>
    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/MySQL/" rel="tag"># MySQL</a>
          
            <a href="/tags/分布式/" rel="tag"># 分布式</a>
          
            <a href="/tags/分库分表/" rel="tag"># 分库分表</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2022/03/20/Git-tutor/" rel="next" title="Git tutor">
                <i class="fa fa-chevron-left"></i> Git tutor
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
        <!-- Go to www.addthis.com/dashboard to customize your tools -->
<div class="addthis_inline_share_toolbox">
  <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5b03d4a278f58ab9" async="async"></script>
</div>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/xiaomai.png" alt="Yu">
            
              <p class="site-author-name" itemprop="name">Yu</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">28</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">30</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yujunjiex" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#什么时候需要分库分表"><span class="nav-number">1.</span> <span class="nav-text">什么时候需要分库分表</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#分库"><span class="nav-number">1.1.</span> <span class="nav-text">分库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#分表"><span class="nav-number">1.2.</span> <span class="nav-text">分表</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#总结"><span class="nav-number">1.3.</span> <span class="nav-text">总结</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#垂直-水平拆分"><span class="nav-number">2.</span> <span class="nav-text">垂直/水平拆分</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#垂直拆分"><span class="nav-number">2.1.</span> <span class="nav-text">垂直拆分</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#拆分特点"><span class="nav-number">2.1.1.</span> <span class="nav-text">拆分特点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#优缺点"><span class="nav-number">2.1.2.</span> <span class="nav-text">优缺点</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#水平拆分"><span class="nav-number">2.2.</span> <span class="nav-text">水平拆分</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#特点"><span class="nav-number">2.2.1.</span> <span class="nav-text">特点</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#优缺点-1"><span class="nav-number">2.2.2.</span> <span class="nav-text">优缺点</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分片算法"><span class="nav-number">3.</span> <span class="nav-text">分片算法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#range"><span class="nav-number">3.1.</span> <span class="nav-text">range</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#hash"><span class="nav-number">3.2.</span> <span class="nav-text">hash</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#一致性hash"><span class="nav-number">3.2.1.</span> <span class="nav-text">一致性hash</span></a></li></ol></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#结合业务场景"><span class="nav-number">4.</span> <span class="nav-text">结合业务场景</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#倒排索引法"><span class="nav-number">4.1.</span> <span class="nav-text">倒排索引法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#基因法"><span class="nav-number">4.2.</span> <span class="nav-text">基因法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分表存在的其他问题"><span class="nav-number">5.</span> <span class="nav-text">分表存在的其他问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#全局id"><span class="nav-number">5.1.</span> <span class="nav-text">全局id</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#范围分片"><span class="nav-number">5.1.1.</span> <span class="nav-text">范围分片</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#UUID-不推荐"><span class="nav-number">5.1.2.</span> <span class="nav-text">UUID(不推荐)</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#Snowflake雪花算法-推荐"><span class="nav-number">5.1.3.</span> <span class="nav-text">Snowflake雪花算法(推荐)</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#跨库-表分页，排序"><span class="nav-number">5.2.</span> <span class="nav-text">跨库/表分页，排序</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#分布式事务"><span class="nav-number">5.3.</span> <span class="nav-text">分布式事务</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#分库分表的工具选型"><span class="nav-number">6.</span> <span class="nav-text">分库分表的工具选型</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heartbeat"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Yu</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">46.7k</span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a></div>



        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>

<script type="text/javascript" src="/custom/fold_action.js?v="></script>





  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//code.bdstatic.com/npm/leancloud-storage@4.12.0/dist/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'rg0EMRYKYKMhOh1zwqEKS5jz-gzGzoHsz',
        appKey: 'T04zQc0OzQd1uxOqcVomoGqj',
        placeholder: '(= =)~*只有10086嘘寒问暖',
        avatar:'mm',
        guest_info:guest,
        pageSize:'5' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  


  

  

  
  

  

  

  


</body>
</html>

